﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace NLBS.Entity
{
    /// <summary>
    /// 
    /// </summary>
    public class UserGroup
    {

        public UserGroup()
        {

        }
        private int _groupID;
        [DataMember]
        public virtual int GroupID
        {
            get { return _groupID; }
            set { _groupID = value; }
        }

        private string _name;
        [DataMember]
        public virtual string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private string _rights;

        public virtual string Rights
        {
            get { return _rights; }
            set
            {
                _rights = value;
                if (_rights != null)
                {
                    string right = Rights;
                    int groupView = int.Parse(_rights.Substring(0, 1));
                    int groupPost = int.Parse(right.Substring(1, 1));
                    int groupEdit = int.Parse(right.Substring(2, 1));
                    int groupDelete = int.Parse(right.Substring(3, 1));
                    int groupUpload = int.Parse(right.Substring(4, 1));

                    if (_power == null)
                        _power = new Right();
                    _power.View = groupView;
                    _power.Post = groupPost;
                    _power.Edit = groupEdit;
                    _power.Delete = groupDelete;
                    _power.Upload = groupUpload;
                }
            }
        }
        private Right _power;
        public virtual Right Power
        {
            get
            {
                if (_power == null)
                    _power = new Right();
                return _power;
            }
            set
            {
                _power = value;
            }
        }

        private Dictionary<string, int> _rightArray;
        public virtual Dictionary<string, int> RightArray
        {
            get
            {
                return _rightArray;
            }
            set
            {
                _rightArray = value;
            }
        }

        [DataMember]
        public virtual IList<User> Users { get; set; }
    }
}
